package com.xtpt.disaster.controller;

import com.xtpt.disaster.bean.NodeInfo;
import com.xtpt.disaster.controller.VO.NodeDirTreeInfo;
import com.xtpt.disaster.service.NodeInfoManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/manage/dirtree")
public class DirTreeController {
    @Autowired
    NodeInfoManageService nodeInfoManageService;

    /**
     * 获取前端的目录路径信息，返回该路径的下级目录信息
     * @param nodeDirTreeInfo
     * @return List<String>下级目录列表
     */
    @PostMapping(value = "getrootdir")
    public List<String> getDirTree(@RequestBody NodeDirTreeInfo nodeDirTreeInfo) {
        Long id = nodeDirTreeInfo.getNodeId();
        String path = nodeDirTreeInfo.getPath();
        List<String> list = new ArrayList<>();
        NodeInfo nodeInfo = nodeInfoManageService.selectById(id);
        if (nodeInfo.getOsType() == 1) {
            //执行windows的盘符查询命令

        }
        else {
            //执行linux根目录下的find

        }
        return list;
    }
}
